package com.concerneyes.mine.TabActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.concerneyes.CEApp;
import com.concerneyes.LoginActivity;
import com.concerneyes.MainActivity;
import com.concerneyes.R;

import common.AbsActivity;
import common.PreferUtil;
import util.ActivityUtil;

/**
 * 设置
 */

public class MySetting extends AbsActivity implements View.OnClickListener {
    private TextView nowVersion;
    private RelativeLayout mRlUpdata;
    private RelativeLayout mRlAboutUs;
    /**
     * 退出登录
     */
    private TextView mTvLogOut;

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_setting);
        String title = getIntent().getExtras().getString("title");
        setTitle(title);
        initView();
    }

    private void initView() {
        nowVersion = (TextView) findViewById(R.id.now_version);
        nowVersion.setText(String.format(getResources().getString(R.string.now_version), CEApp.getVersion()));
        mRlUpdata = (RelativeLayout) findViewById(R.id.rl_updata);
        mRlUpdata.setOnClickListener(this);
        mRlAboutUs = (RelativeLayout) findViewById(R.id.rl_about_us);
        mRlAboutUs.setOnClickListener(this);
        mTvLogOut = (TextView) findViewById(R.id.tv_log_out);
        mTvLogOut.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_updata:
                break;
            case R.id.rl_about_us:
                ActivityUtil.setIntent(this,AboutUsActivity.class,null);
                break;
            case R.id.tv_log_out:
                PreferUtil.saveUserId("");
                CEApp.getInstance().exit();

                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                getApplicationContext().startActivity(intent);
                break;
        }
    }
}
